﻿using System;
using System.Web.Security;
using Application.MainModule.UserManagement;
using Domain.MainModule.Entities;

namespace Presentation.Web.UI.Authentication
{
    public static class AuthenticationExtension
    {
        public static FormsAuthenticationTicket CreateAuthenticationTicket(UserDTO user, bool createPersistentCookie)
        {
            var ticket = new FormsAuthenticationTicket(
                1,
                user.AuthorizationId,
                DateTime.Now,
                DateTime.Now.Add(FormsAuthentication.Timeout),
                createPersistentCookie,
                user.ToString());

            return ticket;
        }
    }
}